package com.lion.appletrip.fragment.item;

import java.util.List;

import com.lion.appletrip.R;
import com.lion.appletrip.WebActivity;
import com.lion.appletrip.model.BannerData;
import com.xinbo.utils.UILUtils;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;

/**
 * A simple {@link Fragment} subclass.
 *
 */
public class FragmenHeadview_banner extends Fragment
{

	private List<BannerData> bannerData;
	private int index;

	public FragmenHeadview_banner(List<BannerData> bannerData, int index)
	{
		this.bannerData = bannerData;
		this.index = index;

	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
	        Bundle savedInstanceState)
	{
		View layout = inflater.inflate(
		        R.layout.fragment_fragmen_headview_banner, container, false);
		BannerData bannerData2 = bannerData.get(index);
		String image_url = bannerData2.getImage_url();
		final String html_url = bannerData2.getHtml_url();
		
		ImageView mImageView = (ImageView) layout.findViewById(R.id.iv_banner);
		UILUtils.displayImage(image_url, mImageView);
		mImageView.setOnClickListener(new OnClickListener()
		{

			@Override
			public void onClick(View v)
			{
				Intent intent = new Intent();
				intent.putExtra("html",html_url);
				intent.setClass(getContext(), WebActivity.class);
				startActivity(intent);
			}
		});
		return layout;
	}
	
}
